package com.android.launcher3.setting;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;

public enum ControlCenterManager {

    INSTANCE;

    private static final String CONTROL_INDEX_KEY = "CONTROL_INDEX_KEY";
    private static final String SP_KEY = "SP_KEY";

    public int getIndex(@NonNull Context context) {
        try {
            return context.getSharedPreferences(SP_KEY, Context.MODE_PRIVATE).getInt(CONTROL_INDEX_KEY, 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;

    }

    @SuppressLint("CommitPrefEdits")
    public void saveIndex(@NonNull Context context, int index) {
        context.getSharedPreferences(SP_KEY, Context.MODE_PRIVATE).edit().putInt(CONTROL_INDEX_KEY, index).apply();
    }

}
